
# coding: utf-8

# In[1]:


import os
os.chdir("E:\pythonstudy")


# In[11]:



info={"a":[123,100],"b":[456,200],"c":[789,300]}#初始化变量，索引值为用户名，123、456、789为密码，100-300为余额

print("="*12,"ATM取款系统","="*12)
print("请登录：")
name=input("账号：")
passwd=int(input("密码："))#输入账号密码进行登录

if info[name][0]==passwd:#登录，如果用户和密码一致，登录成功
    print("登录成功")
    print("{0:1}{1:11}{2:15}".format(" ","1.查询余额","2.存钱"))
    print("{0:1}{1:13}{2:15}".format(" ","3.取钱","4.退出"))
    while True:
        key=int(input("请输入对应的操作："))
        
        #查询余额
        if key==1:
            print("="*12,"查询余额","="*12)
            print("您的余额为{}元".format(info[name][1]))
            
        #存钱
        if key==2:
            print("="*12,"存钱","="*12)
            new_add=float(input("请输入存款金额："))
            if new_add<=0:#如果输入的数小于0
                print("输入错误，请重新输入")
            else:
                info[name][1]+=new_add

            print("您的余额为{}元".format(info[name][1]))
            
        #取钱
        if key==3:
            print("="*12,"取钱","="*12)
            new_add=float(input("请输入存款金额："))
            if new_add>info[name][1]:
                print("输入错误，请重新输入")
            else:
                info[name][1]-=new_add
            print("您的余额为{}元".format(info[name][1]))
        if key==4:
            print("="*12,"退出","="*12)
            break       
elif name not in info.keys():
    print("用户名或密码错误")
else:
    print("用户名或密码错误")


# In[27]:




